<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">






  
  
  <link rel="stylesheet" media="all" href="/lib/Han/dist/han.min.css?v=3.3">




<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/img/icon.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/img/icon.png?v=5.1.3">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="cayun's blog, IT, ACM/ICPC, blog, cayun" />










<meta property="og:type" content="website">
<meta property="og:title" content="cayun&#39;s blog">
<meta property="og:url" content="http://localhost/page/3/index.html">
<meta property="og:site_name" content="cayun&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="cayun&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://localhost/page/3/"/>





  <title>cayun's blog</title>
  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-93052608-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?1ca7c9c8011b37b0c209724dc77c24db";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">cayun's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">不积跬步, 无以至千里!</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6058/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6058/" itemprop="url">hdu 6058 Kanade's sum (贡献 链表)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-05T00:00:00+08:00">
                2017-08-05
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6058/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6058/" class="cy_cmt_count" data-xid="hdu6058/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>对于每一个$a<em>{i}$，求其在$k$位置的贡献，我们可以从大到小枚举，然后对于已经枚举到的数按照位置顺序建立一个链表，那么当取到$a</em>{i}$时，将其插入链表中，然后枚举左边$x$长度，那么右边就是$k-x$长度，枚举的复杂度为$O(k)$，整体的复杂度为$O(nk)$。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="built_in">set</span>&lt;<span class="keyword">int</span>&gt;::iterator SIT;</div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">500010</span>;</div><div class="line"><span class="keyword">int</span> a[N], p[N];</div><div class="line"><span class="keyword">int</span> pre[N], nxt[N];</div><div class="line"><span class="built_in">set</span>&lt;<span class="keyword">int</span>&gt; s;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">(<span class="keyword">int</span> n)</span> </span>&#123;</div><div class="line">    s.clear();</div><div class="line">    <span class="built_in">memset</span>(pre, <span class="number">0</span>, <span class="keyword">sizeof</span> pre);</div><div class="line">    fill(nxt + <span class="number">1</span>, nxt + n + <span class="number">1</span>, n + <span class="number">1</span>);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">connect</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> v)</span> </span>&#123;</div><div class="line">    nxt[u] = v;</div><div class="line">    pre[v] = u;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function">LL <span class="title">getAns</span><span class="params">(<span class="keyword">int</span> p, <span class="keyword">int</span> n, <span class="keyword">int</span> k)</span> </span>&#123;</div><div class="line">    <span class="comment">//cout &lt;&lt; "p = " &lt;&lt; p &lt;&lt; ", pre = " &lt;&lt; pre[p] &lt;&lt; ", nxt = " &lt;&lt; nxt[p] &lt;&lt; endl;</span></div><div class="line">    <span class="keyword">int</span> l = pre[p], r = nxt[p];</div><div class="line">    <span class="keyword">int</span> cnt = <span class="number">0</span>;</div><div class="line">    <span class="keyword">while</span> (cnt &lt; k &amp;&amp; l &gt; <span class="number">0</span>) &#123;</div><div class="line">        l = pre[l];</div><div class="line">        cnt++;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">while</span> (cnt &lt; k &amp;&amp; r &lt;= n) &#123;</div><div class="line">        r = nxt[r];</div><div class="line">        cnt++;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">if</span> (cnt &lt; k) <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">    LL res = <span class="number">0</span>;</div><div class="line">    <span class="keyword">while</span> (l &lt; p &amp;&amp; r &lt;= n + <span class="number">1</span>) &#123;</div><div class="line">        res += (LL)(nxt[l] - l) * (LL)(r - pre[r]);</div><div class="line">        <span class="comment">//cout &lt;&lt; "l = " &lt;&lt; nxt[l] - l &lt;&lt; ", r = " &lt;&lt; r - pre[r] &lt;&lt; endl;</span></div><div class="line">        <span class="keyword">if</span> (r == n + <span class="number">1</span>) <span class="keyword">break</span>;</div><div class="line">        l = nxt[l]; r = nxt[r];</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> res;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    LL ans = <span class="number">0</span>;</div><div class="line">    <span class="keyword">int</span> n, k; <span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;n, &amp;k);</div><div class="line">    init(n);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) &#123;</div><div class="line">        <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;a[i]);</div><div class="line">        p[a[i]] = i;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">int</span> mn = n + <span class="number">1</span>, mx = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = n; i &gt; <span class="number">0</span>; i--) &#123;</div><div class="line">        mn = min(mn, p[i]);</div><div class="line">        mx = max(mx, p[i]);</div><div class="line">        SIT sit = s.upper_bound(p[i]);</div><div class="line">        <span class="keyword">if</span> (sit != s.end()) connect(p[i], *sit);</div><div class="line">        <span class="keyword">if</span> (sit != s.begin()) &#123;</div><div class="line">            sit--;</div><div class="line">            connect(*sit, p[i]);</div><div class="line">        &#125;</div><div class="line">        connect(<span class="number">0</span>, mn);</div><div class="line">        connect(mx, n + <span class="number">1</span>);</div><div class="line">        s.insert(p[i]);</div><div class="line">        ans += i * getAns(p[i], n, k - <span class="number">1</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"%lld\n"</span>, ans);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6060/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6060/" itemprop="url">hdu 6060 RXD and dividing (DFS)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-05T00:00:00+08:00">
                2017-08-05
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6060/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6060/" class="cy_cmt_count" data-xid="hdu6060/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>首先先以$1$为根建树，仔细思考一下可以发现对于每条边，它所能做的最大的贡献是$\max (k, x)$，其中 $x$为该边的子树节点的数量，而且可以发现这个最大值一定可以取到。那么最终直接DFS一遍就可以求出来了。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Edge</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> v; LL w;</div><div class="line">    Edge() &#123;&#125;</div><div class="line">    Edge(<span class="keyword">int</span> a, LL b) &#123;</div><div class="line">        v = a; w = b;</div><div class="line">    &#125;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">1000010</span>;</div><div class="line"><span class="keyword">int</span> sz[N], k;</div><div class="line">LL ans;</div><div class="line"><span class="built_in">vector</span>&lt;Edge&gt; g[N];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">(<span class="keyword">int</span> n)</span> </span>&#123;</div><div class="line">    ans = <span class="number">0</span>;</div><div class="line">    <span class="built_in">memset</span>(sz, <span class="number">0</span>, <span class="keyword">sizeof</span> sz);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) g[i].clear();</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> f)</span> </span>&#123;</div><div class="line">    sz[u]++;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; g[u].size(); i++) &#123;</div><div class="line">        Edge e = g[u][i];</div><div class="line">        <span class="keyword">if</span> (e.v == f) <span class="keyword">continue</span>;</div><div class="line">        dfs(e.v, u);</div><div class="line">        sz[u] += sz[e.v];</div><div class="line">        ans += min(sz[e.v], k) * e.w;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">(<span class="keyword">int</span> n)</span> </span>&#123;</div><div class="line">    init(n);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; n; i++) &#123;</div><div class="line">        <span class="keyword">int</span> u, v; LL c;</div><div class="line">        <span class="built_in">scanf</span>(<span class="string">"%d%d%lld"</span>, &amp;u, &amp;v, &amp;c);</div><div class="line">        g[u].push_back(Edge(v, c));</div><div class="line">        g[v].push_back(Edge(u, c));</div><div class="line">    &#125;</div><div class="line">    dfs(<span class="number">1</span>, <span class="number">0</span>);</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"%lld\n"</span>, ans);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> n;</div><div class="line">    <span class="keyword">while</span> (<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;n, &amp;k) != EOF) solve(n);</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6070/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6070/" itemprop="url">hdu 6070 Dirt Ratio (二分+线段树)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-05T00:00:00+08:00">
                2017-08-05
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6070/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6070/" class="cy_cmt_count" data-xid="hdu6070/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>二分答案，设为$x$，判断是否存在区间$[l,r]$满足$\frac{size(l,r)}{r-l+1} &lt;= x$。移项一下，变为$size(l,r)+x*l&lt;=x*(r+1)$。从左往右枚举$r$，当$r$变为$r+1$时，影响便是$l \in [pre<em>{r+1}+1, r+1]$区间内的$size(l, r+1)$加$1$，$pre</em>{r}$表示与$r$同色的前一个位置，线段树维护$size(l,r)+x * l$的最小值。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> l, r, mark; <span class="keyword">double</span> val;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">60010</span>;</div><div class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-5</span>;</div><div class="line"><span class="keyword">int</span> pos[N], pre[N], a[N];</div><div class="line">Node tree[N &lt;&lt; <span class="number">2</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">buildTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">double</span> x)</span> </span>&#123;</div><div class="line">    tree[u].l = l; tree[u].r = r; tree[u].mark = <span class="number">0</span>;</div><div class="line">    <span class="keyword">if</span> (l + <span class="number">1</span> &lt; r) &#123;</div><div class="line">        <span class="keyword">int</span> mid = (l + r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        buildTree(lch, l, mid, x);</div><div class="line">        buildTree(rch, mid, r, x);</div><div class="line">        tree[u].val = min(tree[lch].val, tree[rch].val);</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        tree[u].val = x * l;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">updateTree</span><span class="params">(<span class="keyword">int</span> u)</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">    tree[lch].val += tree[u].mark; tree[rch].val += tree[u].mark;</div><div class="line">    tree[lch].mark += tree[u].mark; tree[rch].mark += tree[u].mark;</div><div class="line">    tree[u].mark = <span class="number">0</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">incTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (l &lt;= tree[u].l &amp;&amp; tree[u].r &lt;= r) &#123;</div><div class="line">        tree[u].val++;</div><div class="line">        tree[u].mark++;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (tree[u].mark != <span class="number">0</span>) updateTree(u);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">if</span> (l &lt; mid) incTree(lch, l, r);</div><div class="line">        <span class="keyword">if</span> (r &gt; mid) incTree(rch, l, r);</div><div class="line">        tree[u].val = min(tree[lch].val, tree[rch].val);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">double</span> <span class="title">queryTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (l &lt;= tree[u].l &amp;&amp; tree[u].r &lt;= r) &#123;</div><div class="line">        <span class="keyword">return</span> tree[u].val;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (tree[u].mark != <span class="number">0</span>) updateTree(u);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">double</span> mv = <span class="number">0x3f3f3f3f</span>;</div><div class="line">        <span class="keyword">if</span> (l &lt; mid) mv = min(mv, queryTree(lch, l, r));</div><div class="line">        <span class="keyword">if</span> (r &gt; mid) mv = min(mv, queryTree(rch, l, r));</div><div class="line">        <span class="keyword">return</span> mv;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">judge</span><span class="params">(<span class="keyword">double</span> x, <span class="keyword">int</span> n)</span> </span>&#123;</div><div class="line">    buildTree(<span class="number">1</span>, <span class="number">1</span>, n + <span class="number">1</span>, x);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) &#123;</div><div class="line">        incTree(<span class="number">1</span>, pre[i] + <span class="number">1</span>, i + <span class="number">1</span>);</div><div class="line">        <span class="keyword">if</span> (queryTree(<span class="number">1</span>, <span class="number">1</span>, i + <span class="number">1</span>) &lt;= x * (i + <span class="number">1</span>)) <span class="keyword">return</span> <span class="literal">true</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">double</span> <span class="title">myBinary</span><span class="params">(<span class="keyword">double</span> l, <span class="keyword">double</span> r, <span class="keyword">int</span> n)</span> </span>&#123;</div><div class="line">    <span class="keyword">while</span> (l + eps &lt; r) &#123;</div><div class="line">        <span class="keyword">double</span> mid = (l + r) / <span class="number">2</span>;</div><div class="line">        <span class="keyword">if</span> (judge(mid, n)) r = mid;</div><div class="line">        <span class="keyword">else</span> l = mid;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> l;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> n; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;n);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;a[i]);</div><div class="line">    <span class="built_in">memset</span>(pos, <span class="number">0</span>, <span class="keyword">sizeof</span> pos);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) &#123;</div><div class="line">        pre[i] = pos[a[i]];</div><div class="line">        pos[a[i]] = i;</div><div class="line">    &#125;</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"%.5f\n"</span>, myBinary(<span class="number">0</span>, <span class="number">1</span>, n));</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6071/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6071/" itemprop="url">hdu 6071 Lazy Running (动态规划)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-05T00:00:00+08:00">
                2017-08-05
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6071/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6071/" class="cy_cmt_count" data-xid="hdu6071/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>设$w = \min {(d<em>{1,2}, d</em>{2,3})} * 2$，则对于任意可到达的距离$x$，我们都可以到达$x+w$，那么设$dp<em>{i,j}$表示到达第$i$个点，$x \% w = j$的最短距离。求出最短距离后，可以一下就求出不小于$k$的最小的$dp</em>{2,i}+bw$。<br>方便起见，代码中的所有点下标为$0…3$，而不是$1…4$。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">10</span>;</div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> W = <span class="number">60010</span>;</div><div class="line"><span class="keyword">const</span> LL INF = <span class="number">0x3f3f3f3f3f3f3f3f</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> x, y; LL z;</div><div class="line">    Node(<span class="keyword">int</span> a = <span class="number">0</span>, <span class="keyword">int</span> b = <span class="number">0</span>, LL c = <span class="number">0</span>) &#123;</div><div class="line">        x = a; y = b; z = c;</div><div class="line">    &#125;  </div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="keyword">bool</span> <span class="keyword">operator</span>&lt;(<span class="keyword">const</span> Node &amp;a, <span class="keyword">const</span> Node &amp;b) &#123;</div><div class="line">    <span class="keyword">return</span> a.z &gt; b.z;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">int</span> a[<span class="number">10</span>];</div><div class="line">LL dist[N][W];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">run</span><span class="params">(<span class="keyword">int</span> w)</span> </span>&#123;</div><div class="line">    <span class="built_in">memset</span>(dist, <span class="number">-1</span>, <span class="keyword">sizeof</span> dist);</div><div class="line">    priority_queue&lt;Node&gt; q;</div><div class="line">    q.push(Node(<span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>));</div><div class="line">    <span class="keyword">while</span> (!q.empty()) &#123;</div><div class="line">        Node t = q.top(); q.pop();</div><div class="line">        <span class="keyword">if</span> (dist[t.x][t.y] == <span class="number">-1</span>) &#123;</div><div class="line">            dist[t.x][t.y] = t.z;</div><div class="line">            <span class="keyword">int</span> v1 = (t.x + <span class="number">1</span>) % <span class="number">4</span>;</div><div class="line">            <span class="keyword">int</span> v2 = (t.x + <span class="number">3</span>) % <span class="number">4</span>; </div><div class="line">            q.push(Node(v1, (t.y + a[t.x]) % w, t.z + a[t.x]));</div><div class="line">            q.push(Node(v2, (t.y + a[v2]) % w, t.z + a[v2]));</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function">LL <span class="title">getAns</span><span class="params">(LL x, LL w, LL k)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (x &gt;= k) <span class="keyword">return</span> x;</div><div class="line">    LL t = (k - x) / w;</div><div class="line">    <span class="keyword">if</span> ((k - x) % w &gt; <span class="number">0</span>) t++;</div><div class="line">    <span class="keyword">return</span> x + w * t;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    LL k; <span class="built_in">scanf</span>(<span class="string">"%lld"</span>, &amp;k);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">4</span>; i++) <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;a[i]);</div><div class="line">    <span class="keyword">int</span> w = min(a[<span class="number">0</span>], a[<span class="number">1</span>]) &lt;&lt; <span class="number">1</span>;</div><div class="line">    run(w);</div><div class="line">    LL ans = INF;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; w; i++) &#123;</div><div class="line">        <span class="keyword">if</span> (dist[<span class="number">1</span>][i] != <span class="number">-1</span>) &#123;</div><div class="line">            ans = min(ans, getAns(dist[<span class="number">1</span>][i], (LL)w, k));</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"%lld\n"</span>, ans);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6069/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6069/" itemprop="url">hdu 6069 Counting Divisors (筛法)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-04T00:00:00+08:00">
                2017-08-04
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6069/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6069/" class="cy_cmt_count" data-xid="hdu6069/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>设$n=p<em>{1}^{c</em>{1}}p<em>{2}^{c</em>{2}}…p<em>{m}^{c</em>{m}}$，则$d(n^k)=(kc<em>{1}+1)(kc</em>{2}+1)…(kc_{m}+1)$。<br>这题虽然$l,r$很大，但是$r-l$却只有$10^6$，且由于是求因子，所以只要枚举到$\sqrt{r}$即可，那么接下来就用筛法就可以完成了。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">1000010</span>;</div><div class="line"><span class="keyword">const</span> LL MOD = <span class="number">998244353L</span>L;</div><div class="line"><span class="keyword">bool</span> prime[N];</div><div class="line"><span class="built_in">vector</span>&lt;LL&gt; p;</div><div class="line">LL res[N], value[N];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">initPrime</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="built_in">memset</span>(prime, <span class="literal">true</span>, <span class="keyword">sizeof</span> prime);</div><div class="line">    <span class="keyword">int</span> n = <span class="number">1000000</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>; i &lt;= n; i++) &#123;</div><div class="line">        <span class="keyword">if</span> (prime[i]) p.push_back(i);</div><div class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> j = i &lt;&lt; <span class="number">1</span>; j &lt;= n; j += i) prime[j] = <span class="literal">false</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">mp</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> l)</span> </span>&#123;</div><div class="line">    <span class="keyword">return</span> x - l + <span class="number">1</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">handle</span><span class="params">(LL x, LL l, LL r, LL k)</span> </span>&#123;</div><div class="line">    LL p = l / x * x;</div><div class="line">    <span class="keyword">if</span> (p &lt; l) p += x;</div><div class="line">    <span class="keyword">while</span> (p &lt;= r) &#123;</div><div class="line">        LL cnt = <span class="number">0</span>;</div><div class="line">        <span class="keyword">while</span> (value[mp(p, l)] % x == <span class="number">0</span>) &#123;</div><div class="line">            cnt++;</div><div class="line">            value[mp(p, l)] /= x;</div><div class="line">        &#125;</div><div class="line">        res[mp(p, l)] = res[mp(p, l)] * (<span class="number">1</span> + cnt * k) % MOD;</div><div class="line">        p = p + x;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    LL l, r, k;</div><div class="line">    <span class="built_in">scanf</span>(<span class="string">"%lld%lld%lld"</span>, &amp;l, &amp;r, &amp;k);</div><div class="line">    <span class="keyword">for</span> (LL i = l; i &lt;= r; i++) &#123;</div><div class="line">        res[mp(i, l)] = <span class="number">1</span>;</div><div class="line">        value[mp(i, l)] = i;</div><div class="line">    &#125;</div><div class="line">    LL ans = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; p.size(); i++) &#123;</div><div class="line">        handle(p[i], l, r, k);</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">for</span> (LL i = l; i &lt;= r; i++) &#123;</div><div class="line">        <span class="keyword">if</span> (value[mp(i, l)] &gt; <span class="number">1</span>) res[mp(i, l)] = res[mp(i, l)] * (<span class="number">1</span> + k) % MOD;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= r - l + <span class="number">1</span>; i++) &#123;</div><div class="line">        ans += res[i];</div><div class="line">        <span class="keyword">if</span> (ans &gt;= MOD) ans -= MOD;</div><div class="line">    &#125;</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"%lld\n"</span>, ans);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    initPrime();</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6075/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6075/" itemprop="url">hdu 6075 Questionnaire</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-04T00:00:00+08:00">
                2017-08-04
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6075/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6075/" class="cy_cmt_count" data-xid="hdu6075/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>取$m=2$即可。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">int</span> num[<span class="number">2</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> n; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;n);</div><div class="line">    num[<span class="number">0</span>] = num[<span class="number">1</span>] = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</div><div class="line">        <span class="keyword">int</span> x; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;x);</div><div class="line">        num[x &amp; <span class="number">1</span>]++;</div><div class="line">    &#125;</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"2 %d\n"</span>, num[<span class="number">0</span>] &gt;= num[<span class="number">1</span>] ? <span class="number">0</span> : <span class="number">1</span>); </div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu6077/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu6077/" itemprop="url">hdu 6077 Time To Get Up (模拟)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-04T00:00:00+08:00">
                2017-08-04
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu6077/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu6077/" class="cy_cmt_count" data-xid="hdu6077/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>直接模拟，判断笔画即可。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">bool</span> occupy[<span class="number">10</span>][<span class="number">7</span>] = &#123;</div><div class="line">    &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>&#125;, <span class="comment">//0</span></div><div class="line">    &#123;<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>&#125;, <span class="comment">//1</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>&#125;, <span class="comment">//2</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>&#125;, <span class="comment">//3</span></div><div class="line">    &#123;<span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>&#125;, <span class="comment">//4</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>&#125;, <span class="comment">//5</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>&#125;, <span class="comment">//6</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>&#125;, <span class="comment">//7</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>&#125;, <span class="comment">//8</span></div><div class="line">    &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>&#125;&#125;; <span class="comment">//9</span></div><div class="line"><span class="keyword">char</span> s[<span class="number">10</span>][<span class="number">30</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">judge</span><span class="params">(<span class="keyword">int</span> flag, <span class="keyword">int</span> p)</span> </span>&#123;</div><div class="line">    <span class="keyword">switch</span> (flag) &#123;</div><div class="line">        <span class="keyword">case</span> <span class="number">1</span>: <span class="keyword">return</span> s[<span class="number">1</span>][p+<span class="number">2</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">1</span>][p+<span class="number">3</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">2</span>: <span class="keyword">return</span> s[<span class="number">2</span>][p+<span class="number">1</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">3</span>][p+<span class="number">1</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">3</span>: <span class="keyword">return</span> s[<span class="number">2</span>][p+<span class="number">4</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">3</span>][p+<span class="number">4</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">4</span>: <span class="keyword">return</span> s[<span class="number">4</span>][p+<span class="number">2</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">4</span>][p+<span class="number">3</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">5</span>: <span class="keyword">return</span> s[<span class="number">5</span>][p+<span class="number">1</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">6</span>][p+<span class="number">1</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">6</span>: <span class="keyword">return</span> s[<span class="number">5</span>][p+<span class="number">4</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">6</span>][p+<span class="number">4</span>] == <span class="string">'X'</span>;</div><div class="line">        <span class="keyword">case</span> <span class="number">7</span>: <span class="keyword">return</span> s[<span class="number">7</span>][p+<span class="number">2</span>] == <span class="string">'X'</span> &amp;&amp; s[<span class="number">7</span>][p+<span class="number">3</span>] == <span class="string">'X'</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">run</span><span class="params">(<span class="keyword">int</span> p)</span> </span>&#123;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">10</span>; i++) &#123;</div><div class="line">        <span class="keyword">int</span> num = <span class="number">0</span>;</div><div class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; <span class="number">7</span>; j++) &#123;</div><div class="line">            <span class="keyword">if</span> (judge(j + <span class="number">1</span>, p) == occupy[i][j]) &#123;</div><div class="line">                <span class="comment">//cout &lt;&lt; j + 1 &lt;&lt; endl;</span></div><div class="line">                num++;</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        <span class="comment">//printf("num=%d, i=%d\n", num, i);</span></div><div class="line">        <span class="keyword">if</span> (num == <span class="number">7</span>) &#123;</div><div class="line">            <span class="built_in">printf</span>(<span class="string">"%d"</span>, i);</div><div class="line">            <span class="keyword">break</span>;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= <span class="number">7</span>; i++) <span class="built_in">scanf</span>(<span class="string">"%s"</span>, s[i] + <span class="number">1</span>);</div><div class="line">    run(<span class="number">0</span>);</div><div class="line">    run(<span class="number">5</span>);</div><div class="line">    <span class="built_in">printf</span>(<span class="string">":"</span>);</div><div class="line">    run(<span class="number">12</span>);</div><div class="line">    run(<span class="number">17</span>);</div><div class="line">    <span class="built_in">printf</span>(<span class="string">"\n"</span>);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> T; <span class="built_in">scanf</span>(<span class="string">"%d"</span>, &amp;T);</div><div class="line">    <span class="keyword">while</span> (T--) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/gym100341C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/gym100341C/" itemprop="url">Gym 100341C AVL Trees (动态规划+NTT)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-21T00:00:00+08:00">
                2017-07-21
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/gym100341C/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/gym100341C/" class="cy_cmt_count" data-xid="gym100341C/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>设$dp<em>{h,n}$表示高度为$h$，使用$n$个点的方案数，那么不难推出<br>$dp</em>{h,n} = \sum<em>{i=0}^{n-1} {dp</em>{h-1,i} * dp<em>{h-1,n-1-i} + dp</em>{h-1,i} * dp<em>{h-2,n-1-i} + dp</em>{h-1,n-1-i} * dp<em>{h-2,i}}$<br>$ = \sum</em>{i=0}^{n-1} {dp<em>{h-1,i} * (dp</em>{h-1,n-1-i} + 2dp_{h-2,n-1-i})}$<br>那么可以发现该dp方程符合卷积的表达形式，可以使用NTT来进行优化。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Day</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> id, l, r;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">MyTime</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> id, t, flag;</div><div class="line">    MyTime() &#123;&#125;</div><div class="line">    MyTime(<span class="keyword">int</span> id, <span class="keyword">int</span> t, <span class="keyword">int</span> flag) &#123;</div><div class="line">        <span class="keyword">this</span>-&gt;id = id; <span class="keyword">this</span>-&gt;t = t; <span class="keyword">this</span>-&gt;flag = flag;</div><div class="line">    &#125;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> l, r, mx, mn;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">200010</span>;</div><div class="line"><span class="keyword">int</span> n, m;</div><div class="line">Day day[N];</div><div class="line">LL cost[N];</div><div class="line">Node tree[N &lt;&lt; <span class="number">2</span>];</div><div class="line">MyTime myTime[N &lt;&lt; <span class="number">1</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">buildTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span> </span>&#123;</div><div class="line">    tree[u].l = l; tree[u].r = r;</div><div class="line">    tree[u].mx = tree[u].mn = <span class="number">-1</span>;</div><div class="line">    <span class="keyword">if</span> (l + <span class="number">1</span> &lt; r) &#123;</div><div class="line">        <span class="keyword">int</span> mid = (l + r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        buildTree(lch, l, mid);</div><div class="line">        buildTree(rch, mid, r);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">update</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">    <span class="keyword">if</span> (flag &gt;= <span class="number">0</span>) &#123;</div><div class="line">        tree[lch].mn = tree[rch].mn = tree[u].mn;</div><div class="line">        tree[u].mn = <span class="number">-1</span>;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        tree[lch].mx = tree[rch].mx = tree[u].mx;</div><div class="line">        tree[u].mx = <span class="number">-1</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">insertTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">int</span> x, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (l &lt;= tree[u].l &amp;&amp; tree[u].r &lt;= r) &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span>) tree[u].mn = x;</div><div class="line">        <span class="keyword">else</span> tree[u].mx = x;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span> &amp;&amp; tree[u].mn != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">if</span> (flag &lt; <span class="number">0</span> &amp;&amp; tree[u].mx != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">if</span> (l &lt; mid) insertTree(lch, l, r, x, flag);</div><div class="line">        <span class="keyword">if</span> (r &gt; mid) insertTree(rch, l, r, x, flag);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">queryTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> p, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (tree[u].l + <span class="number">1</span> == tree[u].r) &#123;</div><div class="line">        <span class="keyword">return</span> flag &gt;= <span class="number">0</span> ? tree[u].mn : tree[u].mx;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span> &amp;&amp; tree[u].mn != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">if</span> (flag &lt; <span class="number">0</span> &amp;&amp; tree[u].mx != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">return</span> p &lt; mid ? queryTree(lch, p, flag) : queryTree(rch, p, flag);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmpMyTime</span><span class="params">(<span class="keyword">const</span> MyTime &amp;a, <span class="keyword">const</span> MyTime &amp;b)</span> </span>&#123;</div><div class="line">    <span class="keyword">return</span> a.t == b.t ? a.id &lt; b.id : a.t &lt; b.t;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; n; i++) <span class="built_in">scanf</span>(<span class="string">"%lld"</span>, &amp;cost[i]);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) &#123;</div><div class="line">        day[i].id = i;</div><div class="line">        <span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;day[i].l, &amp;day[i].r);</div><div class="line">        <span class="keyword">if</span> (day[i].l &gt; day[i].r) swap(day[i].l, day[i].r);</div><div class="line">    &#125;</div><div class="line">    buildTree(<span class="number">1</span>, <span class="number">1</span>, n);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) insertTree(<span class="number">1</span>, day[i].l ,day[i].r, i + <span class="number">1</span>, <span class="number">-1</span>);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = m; i &gt; <span class="number">0</span>; i--) insertTree(<span class="number">1</span>, day[i].l, day[i].r, i, <span class="number">1</span>);</div><div class="line">    <span class="keyword">int</span> tn = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; n; i++) &#123;</div><div class="line">        myTime[tn++] = MyTime(i, queryTree(<span class="number">1</span>, i, <span class="number">1</span>), <span class="number">1</span>);</div><div class="line">        <span class="keyword">if</span> (myTime[tn<span class="number">-1</span>].t &lt;= <span class="number">0</span>) tn--;</div><div class="line">        myTime[tn++] = MyTime(i, queryTree(<span class="number">1</span>, i, <span class="number">-1</span>), <span class="number">-1</span>);</div><div class="line">        <span class="keyword">if</span> (myTime[tn<span class="number">-1</span>].t &lt;= <span class="number">0</span>) tn--;</div><div class="line">    &#125;</div><div class="line">    sort(myTime, myTime + tn, cmpMyTime);</div><div class="line">    LL pos = <span class="number">0</span>, sum = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) &#123;</div><div class="line">        <span class="keyword">while</span> (pos &lt; tn &amp;&amp; myTime[pos].t &lt;= i) &#123;</div><div class="line">            sum += cost[myTime[pos].id] * myTime[pos].flag;</div><div class="line">            pos++;</div><div class="line">        &#125;</div><div class="line">        <span class="built_in">cout</span> &lt;&lt; sum &lt;&lt; <span class="string">"\n"</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">while</span> (<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;n, &amp;m) != EOF) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/hdu5861/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/hdu5861/" itemprop="url">hdu 5861 Road (线段树)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-20T00:00:00+08:00">
                2017-07-20
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/hdu5861/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/hdu5861/" class="cy_cmt_count" data-xid="hdu5861/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>首先对于每一段路径，通过线段树可以计算出其开放时间和关闭时间，然后接下来新建一个数组记录id, time, flag，分别表示第id段路，时间，状态（开放或关闭），之后对该数组进行排序，就可以很容易就可以一个一个求出每一天的花费。</p>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight cpp"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Day</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> id, l, r;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">MyTime</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> id, t, flag;</div><div class="line">    MyTime() &#123;&#125;</div><div class="line">    MyTime(<span class="keyword">int</span> id, <span class="keyword">int</span> t, <span class="keyword">int</span> flag) &#123;</div><div class="line">        <span class="keyword">this</span>-&gt;id = id; <span class="keyword">this</span>-&gt;t = t; <span class="keyword">this</span>-&gt;flag = flag;</div><div class="line">    &#125;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span> &#123;</span></div><div class="line">    <span class="keyword">int</span> l, r, mx, mn;</div><div class="line">&#125;;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> LL;</div><div class="line"><span class="keyword">const</span> <span class="keyword">int</span> N = <span class="number">200010</span>;</div><div class="line"><span class="keyword">int</span> n, m;</div><div class="line">Day day[N];</div><div class="line">LL cost[N];</div><div class="line">Node tree[N &lt;&lt; <span class="number">2</span>];</div><div class="line">MyTime myTime[N &lt;&lt; <span class="number">1</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">buildTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span> </span>&#123;</div><div class="line">    tree[u].l = l; tree[u].r = r;</div><div class="line">    tree[u].mx = tree[u].mn = <span class="number">-1</span>;</div><div class="line">    <span class="keyword">if</span> (l + <span class="number">1</span> &lt; r) &#123;</div><div class="line">        <span class="keyword">int</span> mid = (l + r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        buildTree(lch, l, mid);</div><div class="line">        buildTree(rch, mid, r);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">update</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">int</span> lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">    <span class="keyword">if</span> (flag &gt;= <span class="number">0</span>) &#123;</div><div class="line">        tree[lch].mn = tree[rch].mn = tree[u].mn;</div><div class="line">        tree[u].mn = <span class="number">-1</span>;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        tree[lch].mx = tree[rch].mx = tree[u].mx;</div><div class="line">        tree[u].mx = <span class="number">-1</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">insertTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">int</span> x, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (l &lt;= tree[u].l &amp;&amp; tree[u].r &lt;= r) &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span>) tree[u].mn = x;</div><div class="line">        <span class="keyword">else</span> tree[u].mx = x;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span> &amp;&amp; tree[u].mn != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">if</span> (flag &lt; <span class="number">0</span> &amp;&amp; tree[u].mx != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">if</span> (l &lt; mid) insertTree(lch, l, r, x, flag);</div><div class="line">        <span class="keyword">if</span> (r &gt; mid) insertTree(rch, l, r, x, flag);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">queryTree</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> p, <span class="keyword">int</span> flag)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (tree[u].l + <span class="number">1</span> == tree[u].r) &#123;</div><div class="line">        <span class="keyword">return</span> flag &gt;= <span class="number">0</span> ? tree[u].mn : tree[u].mx;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (flag &gt;= <span class="number">0</span> &amp;&amp; tree[u].mn != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">if</span> (flag &lt; <span class="number">0</span> &amp;&amp; tree[u].mx != <span class="number">-1</span>) update(u, flag);</div><div class="line">        <span class="keyword">int</span> mid = (tree[u].l + tree[u].r) &gt;&gt; <span class="number">1</span>, lch = u &lt;&lt; <span class="number">1</span>, rch = lch | <span class="number">1</span>;</div><div class="line">        <span class="keyword">return</span> p &lt; mid ? queryTree(lch, p, flag) : queryTree(rch, p, flag);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmpMyTime</span><span class="params">(<span class="keyword">const</span> MyTime &amp;a, <span class="keyword">const</span> MyTime &amp;b)</span> </span>&#123;</div><div class="line">    <span class="keyword">return</span> a.t == b.t ? a.id &lt; b.id : a.t &lt; b.t;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">solve</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; n; i++) <span class="built_in">scanf</span>(<span class="string">"%lld"</span>, &amp;cost[i]);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) &#123;</div><div class="line">        day[i].id = i;</div><div class="line">        <span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;day[i].l, &amp;day[i].r);</div><div class="line">        <span class="keyword">if</span> (day[i].l &gt; day[i].r) swap(day[i].l, day[i].r);</div><div class="line">    &#125;</div><div class="line">    buildTree(<span class="number">1</span>, <span class="number">1</span>, n);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) insertTree(<span class="number">1</span>, day[i].l ,day[i].r, i + <span class="number">1</span>, <span class="number">-1</span>);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = m; i &gt; <span class="number">0</span>; i--) insertTree(<span class="number">1</span>, day[i].l, day[i].r, i, <span class="number">1</span>);</div><div class="line">    <span class="keyword">int</span> tn = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; n; i++) &#123;</div><div class="line">        myTime[tn++] = MyTime(i, queryTree(<span class="number">1</span>, i, <span class="number">1</span>), <span class="number">1</span>);</div><div class="line">        <span class="keyword">if</span> (myTime[tn<span class="number">-1</span>].t &lt;= <span class="number">0</span>) tn--;</div><div class="line">        myTime[tn++] = MyTime(i, queryTree(<span class="number">1</span>, i, <span class="number">-1</span>), <span class="number">-1</span>);</div><div class="line">        <span class="keyword">if</span> (myTime[tn<span class="number">-1</span>].t &lt;= <span class="number">0</span>) tn--;</div><div class="line">    &#125;</div><div class="line">    sort(myTime, myTime + tn, cmpMyTime);</div><div class="line">    LL pos = <span class="number">0</span>, sum = <span class="number">0</span>;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) &#123;</div><div class="line">        <span class="keyword">while</span> (pos &lt; tn &amp;&amp; myTime[pos].t &lt;= i) &#123;</div><div class="line">            sum += cost[myTime[pos].id] * myTime[pos].flag;</div><div class="line">            pos++;</div><div class="line">        &#125;</div><div class="line">        <span class="built_in">cout</span> &lt;&lt; sum &lt;&lt; <span class="string">"\n"</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">while</span> (<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>, &amp;n, &amp;m) != EOF) solve();</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://localhost/codeforces825E/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cayun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/img/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cayun's blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/codeforces825E/" itemprop="url">codeforces 825E Minimal Labels (拓扑排序)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-19T00:00:00+08:00">
                2017-07-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/ACM-ICPC/" itemprop="url" rel="index">
                    <span itemprop="name">ACM/ICPC</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/codeforces825E/#SOHUCS" itemprop="discussionUrl">
                  <span id="url::http://localhost/codeforces825E/" class="cy_cmt_count" data-xid="codeforces825E/" itemprop="commentsCount" ></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          <h1 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</h1><p>这一题直接按照题意所说的顺序，很显然可以发现就是一个拓扑排序。但是题目却有个超坑的要求，就是要求字典序最小，这个时候发现好像不好使用拓扑了，哪怕对每个点设置优先级来拓扑也会出现各种各样的问题。事实上，我们只要进行反向拓扑，并且每次只取最大的那个点就可以满足要求，这样大的会尽可能在后面，反言之，就是小的会尽可能在前面。</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/codeforces825E/" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/2/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/">2</a><span class="page-number current">3</span><a class="page-number" href="/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/11/">11</a><a class="extend next" rel="next" href="/page/4/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/img/head.png"
                alt="cayun" />
            
              <p class="site-author-name" itemprop="name">cayun</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">102</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">3</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">79</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="https://github.com/comeacrossyun" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:comeacrossyun@gmail.com" target="_blank" title="E-Mail">
                    
                      <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                </span>
              
            
          </div>

          
          

          
          

          

        </div>
      </section>

      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">cayun</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a></div>




        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.3"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  




  
    <script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cyt6VLWhj"></script>
  









  





  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

</body>
</html>
